﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _4DJackPot
{
    public partial class ChangePassword : Dock
    {
        public ChangePassword()
        {
            InitializeComponent();
            textBox6.Text = Global.idString;
            textBox1.Text = Global.nameString;
           
        }

        private void bTn_Exit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (this.textBox4.Text.Equals(this.textBox5.Text))
            {
                //db내용 update
                string selectQueryString =
                "UPDATE `users` " +
                "SET `password` = '" + textBox4.Text + "'"+
                "WHERE `user_id` = '" + Global.idString + "'";

                DbConn DbConn = new DbConn();

                // DbConn에 ReadQuery 호출 하면 해당 쿼리가 실행되어 DataSet으로 Return됨
                DataSet resultReadDataSet = DbConn.ReadQuery(selectQueryString);

                MessageBox.Show("You have successfully changed password.", "Help", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            else
            {
                MessageBox.Show("The entered passwords are not same.", "Help", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            
            return;
        }
    }
}
